package clsaa;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;

public class AllBiglotto {
    private List<Biglotto> allData=new ArrayList<Biglotto>();
    private int[] dataA=new int[35];
    private int[] dataB=new int[12];
    private double[] dataAV=new double[35];
    private double[] dataBV=new double[12];

    public AllBiglotto() {
    }
    public void initDataNum(){
        for(int i=0;i<35;++i){
            dataA[i]=0;
            if(i<12)dataB[i]=0;
        }
        for(Biglotto biglotto:allData){
            dataA[biglotto.getA()-1]++;
            dataA[biglotto.getB()-1]++;
            dataA[biglotto.getC()-1]++;
            dataA[biglotto.getD()-1]++;
            dataA[biglotto.getE()-1]++;
            dataB[biglotto.getF()-1]++;
            dataB[biglotto.getG()-1]++;
        }
        for(int i=0;i<35;++i){
            dataAV[i]=((dataA[i]*1.0)/(allData.size()*1.0))*100;
        }
        for(int i=0;i<12;++i){
            dataBV[i]=((dataB[i]*1.0)/(allData.size()*1.0))*100;
        }
    }
    public AllBiglotto(List<Biglotto> allData) {
        this.allData = allData;
    }

    public List<Biglotto> getAllData() {
        return allData;
    }

    public int[] getDataA() {
        return dataA;
    }

    public void setDataA(int[] dataA) {
        this.dataA = dataA;
    }

    public double[] getDataAV() {
        return dataAV;
    }

    public void setDataAV(double[] dataAV) {
        this.dataAV = dataAV;
    }

    public double[] getDataBV() {
        return dataBV;
    }

    public void setDataBV(double[] dataBV) {
        this.dataBV = dataBV;
    }

    public int[] getDataB() {
        return dataB;
    }

    public void setDataB(int[] dataB) {
        this.dataB = dataB;
    }

    public void setAllData(List<Biglotto> allData) {
        this.allData = allData;
    }
    public void add(Biglotto Data) {
        this.allData.add(Data);
    }
    public void reorderDescend() {
        // 使用自定义的Comparator进行排序
        Collections.sort(allData, new Comparator<Biglotto>() {
            @Override
            public int compare(Biglotto o1, Biglotto o2) {
                // 升序排序
                return Integer.compare(o2.getId(), o1.getId());
                // 如果需要降序排序，则交换o1和o2的位置
                // return Integer.compare(o2.getId(), o1.getId());
            }
        });

        // 输出排序后的List
        for (Biglotto obj : allData) {
            System.out.println(obj);
        }
    }
    public void reorderAscending() {
        // 使用自定义的Comparator进行排序
        Collections.sort(allData, new Comparator<Biglotto>() {
            @Override
            public int compare(Biglotto o1, Biglotto o2) {
                // 升序排序
                return Integer.compare(o1.getId(), o2.getId());
                // 如果需要降序排序，则交换o1和o2的位置
                // return Integer.compare(o2.getId(), o1.getId());
            }
        });

        // 输出排序后的List
        for (Biglotto obj : allData) {
            System.out.println(obj);
        }
    }
}
